/*    */ package com.openbravo.pos.forms;
/*    */ 
/*    */ import com.openbravo.pos.scripting.ScriptEngine;
/*    */ import com.openbravo.pos.scripting.ScriptException;
/*    */ import com.openbravo.pos.scripting.ScriptFactory;
/*    */ import com.openbravo.pos.util.StringUtils;
/*    */ import java.io.IOException;
/*    */ 
/*    */ public class BeanFactoryScript
/*    */   implements BeanFactoryApp
/*    */ {
/* 34 */   private BeanFactory bean = null;
/*    */   private String script;
/*    */ 
/*    */   public BeanFactoryScript(String script)
/*    */   {
/* 38 */     this.script = script;
/*    */   }
/*    */ 
/*    */   public void init(AppView app) throws BeanFactoryException
/*    */   {
/*    */     try
/*    */     {
/* 45 */       ScriptEngine eng = ScriptFactory.getScriptEngine("beanshell");
/* 46 */       eng.put("app", app);
/*    */ 
/* 48 */       this.bean = ((BeanFactory)eng.eval(StringUtils.readResource(this.script)));
/* 49 */       if (this.bean == null)
/*    */       {
/* 51 */         this.bean = ((BeanFactory)eng.get("bean"));
/*    */       }
/*    */ 
/* 55 */       if ((this.bean instanceof BeanFactoryApp))
/* 56 */         ((BeanFactoryApp)this.bean).init(app);
/*    */     }
/*    */     catch (ScriptException e) {
/* 59 */       throw new BeanFactoryException(e);
/*    */     } catch (IOException e) {
/* 61 */       throw new BeanFactoryException(e);
/*    */     }
/*    */   }
/*    */ 
/*    */   public Object getBean() {
/* 66 */     return this.bean.getBean();
/*    */   }
/*    */ }

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.forms.BeanFactoryScript
 * JD-Core Version:    0.6.0
 */